<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body style="padding:10px;">
  <div class="tplay-body-div">
    <div style="margin-top: 20px;">
    </div>
    <form class="layui-form" id="admin">
      <div style="padding: 50px; line-height: 22px; font-weight: 700;" id="number">
        <input type="hidden" name="uid" value="{$uid}">
        <div class="layui-input-inline">
          <select name="year" lay-filter="first" id="first" lay-filter="aihao">
            <option value="">=请选择=</option>

            <option value=""></option>

          </select>
        </div>
        <table border="1" cellspacing="0" width="100%" height="100%">
          <tr>
            <td width="19%" rowspan="2" valign="center" style="text-align:center" >
              <h2><strong>项目</strong></h2></td>
          </tr>
          <tr >
            <td width="14%" valign="center" style="text-align:center"><h2><strong>金额</strong></h2></td></td>
          </tr>
          <tr >
            <td valign="center" ><p align="center" ><strong>取暖费</strong><strong> </strong></p></td>
            <td valign="center" ><input name="qunuanfei" placeholder="请输入金额" lay-verify="required" value="" autocomplete="off" class="layui-input" type="number"></td>
          </tr>
          <tr >
            <td valign="center" ><p align="center" ><strong>租房费</strong><strong> </strong></p></td>
            <td valign="center" ><input name="zufangfei" placeholder="请输入金额" lay-verify="required" value="" autocomplete="off" class="layui-input" type="number"></td>
          </tr>
          <tr >
            <td valign="center" ><p align="center" ><strong>生活补助</strong><strong> </strong></p></td>
            <td valign="center" ><input name="shenghuobu" placeholder="请输入金额" lay-verify="required" value="" autocomplete="off" class="layui-input" type="number"></td>
          </tr>
          <tr >
            <td valign="center" ><p align="center" ><strong>搬家补助</strong><strong> </strong></p></td>
            <td valign="center" ><input name="banjiabu" placeholder="请输入金额" lay-verify="required" value="" autocomplete="off" class="layui-input" type="number"></td>
          </tr>
          <tr >
            <td valign="center" ><p align="center" ><strong>其它1</strong><strong> </strong></p></td>
            <td valign="center" ><input name="qita1" placeholder="请输入金额" lay-verify="required" value="" autocomplete="off" class="layui-input" type="number"></td>
          </tr>
          <tr >
            <td valign="center" ><p align="center" ><strong>合计</strong><strong> </strong></p></td>
            <td valign="center" ><input name="sum" id="sum" lay-verify="required" value="0" readonly autocomplete="off" class="layui-input" type="text"></td>
          </tr>
        </table>
      </div>
      <div class="layui-form-item" >
        <div class="layui-input-block" style="text-align: center">
          <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
          <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
      </div>
    </form>
    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script>
      $("input[type=number]").blur(function(){
        var valueArr= $('input[type=number]');
        var sumValue=0;
        if(valueArr.size()>0||valueArr != null){
             for (var i=0;i<valueArr.size();i++ )
              {    
                  if(isNaN(valueArr[i].value)||valueArr[i].value==null||valueArr[i].value==""){
                     sumValue +=0;
                  }
                  else{
                     sumValue +=parseFloat(valueArr[i].value);
                  }
              }
        }
         if(sumValue>0){
              $('#sum').val(parseInt(sumValue));
         }else{
             $('#sum').val(0);
         }
      })
    </script>
    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
          elem: '#test1'
        });
    })
    </script>
    <script>
      layui.use(['layer', 'form'], function() {
          var layer = layui.layer,
              $ = layui.jquery,
              form = layui.form;
          $(window).on('load', function() {
              form.on('submit(admin)', function(data) {
                  $.ajax({
                      url:"{:url('admin/subsidy/subsidy_addnew')}",
                      data:$('#admin').serialize(),
                      type:'post',
                      async: false,
                      success:function(res) {
                        if(res.code == 1) {
                            layer.alert('提交成功！',{icon:6},parent.location.reload());
                        }else {
                            layer.msg(res.msg);
                        }
                      }
                  })
                  return false;
              });
          });
      });
    </script>
  </div>
</body>
</html>